#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>


/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	
	eay();
	
}

void eay(){
	
	char a [50][50] = {
	"##############",
	"#@        ####",
	"###   #  #####",
	"###          #",
	"##############"};
	
	int i;
	char ch;
	int x = 1;
	int y = 1;
	int endx = 12;
	int endy = 3;
	
	while(1){
		if(x==endx&&y==endy){
			printf("xx\n");
			break;
		}
		 
		 for(i=0;i<5;i++){
		 	puts(a[i]);
		 }
		 
		 ch=getch();
		 
		 if(ch =='w'){
		 	if(a[y-1][x]!='#'){
		 		a[y][x] = ' ';
		 		y--;
		 		a[y][x] = '@';
 			 }
		 }
		 
		 if(ch =='d'){
		 	if(a[y][x+1]!='#'){
		 		a[y][x] = ' ';
		 		x++;
		 		a[y][x] = '@';
 			 }
		 }
		 
		 if(ch =='a'){
		 	if(a[y][x-1]!='#'){
		 		a[y][x] = ' ';
		 		x--;
		 		a[y][x] = '@';
 			 }
		 }
		 
		 if(ch =='s'){
		 	if(a[y+1][x]!='#'){
		 		a[y][x] = ' ';
		 		y++;
		 		a[y][x] = '@';
 			 }
		 }
		 system("cls");
	}
}


